<?php
require_once 'Translator/Controller.php';

class LanguageController extends Translator_Controller
{
	/**
	 * View a language.
	 */
	public function viewAction() {
		$code = $this->_getParam('code');
		
		require_once 'models/LanguageModel.php';
		$languageModel = new LanguageModel();
		
		require_once 'models/BundleModel.php';
		$bundleModel = new BundleModel();
		
		$language = $languageModel->fetchLanguage($code);
		
		if(empty($language)) {
			$this->_forward('error404', 'error');
			return;
		}
		
		$bundles = $bundleModel->fetchBundlesAndStats($language->id);
		
		$this->view->language = $language;
		$this->view->bundles = $bundles;
	}
}